<?php
// $Id: Installer.php 27 2010-11-16 12:49:54Z mjohnson60@gmail.com $

/**
 * Enter description here ...
 * 
 * @author Mark Phillip Johnson
 * @version 1.0
 * @copyright Copyright (c) 2010, markjohnson
 * @license http://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
 *
 */
abstract class Installer extends Object
{
	/**
	 * @var unknown_type Enter description here ...
	 */
	var $name = '';
	
	/**
	 * @var unknown_type Enter description here ...
	 */
	var $dependencies = array();
	
	/**
	 * @var unknown_type Enter description here ...
	 */
	var $description = '';
	
	/**
	 * @var unknown_type Enter description here ...
	 */
	var $schema_version = -1;
	
	/**
	 * @var unknown_type Enter description here ...
	 */
	var $php = HERMES_MINIMUM_PHP;
	
	/**
	 * @var unknown_type Enter description here ...
	 */
	var $weight = 0;
	
	/**
	 * @var unknown_type Enter description here ...
	 */
	var $initialize = 0;

	/**
	 * install()
	 * 
	 * Enter description here ...
	 * 
	 */
	public function install()
	{
		if (method_exists($this, 'schema'))
		{
			Athena::installSchema($this->name);
		}
	}

	/**
	 * uninstall()
	 * 
	 * Enter description here ...
	 * 
	 */
	public function uninstall()
	{
		if (method_exists($this, 'schema'))
		{
			Athena::uninstallSchema($this->name);
		}
	}
	
	/**
	 * schema()
	 * 
	 * Enter description here ...
	 * 
	 * @return multitype:
	 */
	public static function schema() 
	{
		return array();
	}
	
	/**
	 * installSchema()
	 * 
	 * Enter description here ...
	 * 
	 * @return boolean
	 */
	public static function installSchema() 
	{
		$schema = $this->schema();
			
		$return = TRUE;
		foreach ($schema as $name => $table)
		{
			$result = Db::query($table);
			
			$return = $return && ($result !== FALSE);
		}
		
		return $return;
	}
}
